package com.demo.web.modules.sys;

import com.demo.common.constant.api.base.BaseController;
import com.demo.common.result.ResponseInfo;
import com.demo.common.result.ResultVo;
import com.demo.dao.sys.entity.SysUserItem;
import com.demo.service.sys.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/sys/user")
public class SysUserController extends BaseController<SysUserItem, Long> {

    @Autowired
    SysUserService sysUserService;

    @RequestMapping(value = "/upload", method = RequestMethod.POST)
    public ResultVo uploadExcel(MultipartFile file){
        try{
            sysUserService.importExcel(file);
            return ResponseInfo.success();
        }catch (Exception ex){
            return ResponseInfo.fail("上传失败！");
        }
    }
}
